/**
 * PeriodTask.java
 * Jan 9, 2010
 */
package com.dlplay.flightinfo.core;

import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.dlplay.flightinfo.data.AirFlightCode;
import com.dlplay.flightinfo.data.FlightInfo;
import com.dlplay.flightinfo.data.RealTimeFlightInfo;
import com.dlplay.flightinfo.db.FlightInfoDbMngr;
import com.dlplay.flightinfo.source.DataSourceManager;

/**
 * @author zhao yu
 * 
 */
public class PeriodManager {
	private static final Logger log = Logger.getLogger(PeriodManager.class.getName());		
	
	private static PeriodManager instance;
	public static PeriodManager getInstance()
	{
		if(instance==null)
			instance = new PeriodManager();
		
		return instance;
	}
	
	/*
	 * update the flight infomation in DB
	 * 1. find the data source
	 * 2. get the data
	 * 3. update the DB		 
	 */
	public void updateFlights()
	{		
		log.info("update register flights");
		List<AirFlightCode> flights = FlightSystem.getFlightInfoDbManager().getRegisteredFlights();
		for (AirFlightCode flightNum : flights)
		{
			RealTimeFlightInfo info = FlightSystem.getFlightManager().getRealTimeFlightInfo(flightNum);
			if(info==null)
			{
				log.log(Level.WARNING, "get info failed: "+flightNum);
			}
		}

	}	
}
